<template>
    <a-drawer
        :maskClosable="true"
        :width="drawerWidth"
        placement="right"
        :closable="true"
        @close="handleCancel"
        :visible="visible">

        <template  slot="title">
            <div style="width: 100%;">
                <span>{{ title }}</span>
                <span style="display:inline-block;width:calc(100% - 51px);padding-right:10px;text-align: right">
                    <a-button @click="toggleScreen" icon="appstore" style="height:20px;width:20px;border:0px"></a-button>
                </span>
            </div>
        </template>


        <a-spin :spinning="confirmLoading" class="drawer-content">
            <a-form :form="form">
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="编码">
                <a-input autocomplete="off" placeholder="请输入编码" v-decorator="['no', {rules:getValidatorRolesRequired(10)} ]"/>
              </a-form-item>
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="名称"
                :hidden="false"
                hasFeedback >
                <a-input autocomplete="off" placeholder="请输入区域名称" v-decorator="['name', { rules: getValidatorRolesRequired(100) }]"/>
              </a-form-item>

              <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"  label="上级区域" v-if="!!model.parentId">
                <ak-tree-select :url="url.tree" v-decorator="['parentId', {rules:model.parentId?getValidatorRolesRequired():[] } ]"/>
              </a-form-item>

              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="排序">
                <a-input-number placeholder="请输入排序" v-decorator="['sort',{rules:getValidatorRolesRequired()}]" />
              </a-form-item>
              <a-form-item
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                label="类型">
                <ak-dict-select-tag dict-code="RegionTypeEnum" placeholder="请输入类型" v-decorator="['type', ,{rules:getValidatorRolesRequired()}]"  />
              </a-form-item>

              <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol"  label="边界经纬度" >
                <a-textarea  v-decorator="['position', {} ]"></a-textarea>
              </a-form-item>
            </a-form>
        </a-spin>
            <div class="drawer-bootom-button" v-show="!disableSubmit">
                <a-popconfirm title="确定放弃编辑？" @confirm="handleCancel" okText="确定" cancelText="取消">
                    <a-button style="margin-right: .8rem">取消</a-button>
                </a-popconfirm>
                <a-button @click="handleSubmit" type="primary" :loading="confirmLoading">提交</a-button>
            </div>

    </a-drawer>
</template>

<script>
    import AkfhModelDrawMixin from '../../../mixin/AkfhModelDrawMixin';
    import {baseRegionUrl} from '../../../api/url'

    import AkTreeSelect from "../../../components/akfh/AkTreeSelect";
    import AkDictSelectTag from '../../../components/akfh/AkDictSelectTag'
    export default {
        name: 'BaseRegionModel',
        components: { AkDictSelectTag, AkTreeSelect },
        mixins:[AkfhModelDrawMixin],

        data(){
            return {

                validatorRules:{
                },
                url:baseRegionUrl,
            }
        },


    }
</script>

<style scoped>

</style>
